"""
File   : 02_embeddings.py
Desc   : 嵌入向量化
Date   : 2024/11/27
Author : Tianyu Chen
"""


from openai import OpenAI
client = OpenAI()

response = client.embeddings.create(
    model="text-embedding-3-large",
    input="The food was delicious and the waiter..."
)

print(response.data[0].embedding)
""" output:
[
    -0.011013544, 
    0.002753386, 
    -0.005739084, 
    -0.00807529, 
    0.0006703505,
    ...
    -0.026254509, 
    -0.004044189
]
"""

# print(response)
""" output:
CreateEmbeddingResponse(
    data=[
        Embedding(
            embedding=[
                -0.011013544, 
                0.002753386, 
                -0.005739084, 
                -0.00807529, 
                0.0006703505,
                ...
                -0.026254509, 
                -0.004044189
            ], 
            index=0, 
            object='embedding'
        )
    ], 
    model='text-embedding-3-large', 
    object='list', 
    usage=Usage(
        prompt_tokens=8, 
        total_tokens=8
    )
)
"""
